# coding=utf-8
from wtforms import Form, StringField, IntegerField, DateTimeField
from wtforms.validators import regexp, Length, DataRequired


class VoucherForm(Form):
    shopID = IntegerField(validators=[DataRequired(message="请传入id")])
    title = StringField(validators=[Length(1, 50, message="标题长度不符合规范！")])
    subTitle = StringField(validators=[Length(0, 50, message="子标题长度不符合规范！")])
    rules = StringField(validators=[Length(0, 200, message="使用规则长度不符合规范！")])
    payValue = IntegerField(validators=[DataRequired(message="请输入优惠券购买金额！")])  # 支付金额，单位是分。例如200代表2元
    actualValue = IntegerField(validators=[DataRequired(message="请输入优惠券抵扣金额！")])  # 抵扣金额，单位是分。例如200代表2元
    type = IntegerField(validators=[DataRequired(message="请输入优惠券类型！")])  # 0,普通券；1,秒杀券
    status = IntegerField(validators=[DataRequired(message="请输入优惠券状态！")])  # 1,上架; 2,下架; 3,过期


class SecKillVoucherForm(VoucherForm):
    stock = IntegerField(validators=[DataRequired(message="请输入优惠券库存")])  # 库存
    beginTime = DateTimeField(validators=[DataRequired(message='请输入优惠券开始时间')])
    endTime = DateTimeField(validators=[DataRequired(message='请输入优惠券结束时间')])

